/*
@name Banner Detect
@version 0.1
@description Banner Based Server Detection
@active false
*/

var signatures = [
'abyss','abyss',
'alchemyeye','Alchemy Eye',
'apache','apache',
'apache','apache-coyote',
'apache','infrastructure',
'apache','jakarta',
'apache','tomcat',
'apache','IBM_HTTP_SERVER',
'cern','cern',
'citrix','citrix',
'compaq','CompaqHTTPServer',
'dhost','dhost',
'dhost','httpstk',
'dwhttpd','dwhttpd',
'goaheadwebs','GoAhead-Webs',
'iis','iis',
'iis','online',
'iis','personal web',
'iis','pws',
'iis','speleoweb',
'jeus','Jeus WebContainer',
'jeus','WebtoB',
'jrun','jrun',
'lotus','domino',
'lotus','lotus',
'mipcd','mofet',
'msmfc','MS-MFC-HttpSvr',
'mycio','mycio',
'mywebserver','mywebserver',
'ncsa','ncsa',
'netapp','NetApp',
'netscape','iplanet',
'netscape','netscape',
'netscape','Sun-ONE-Web-Server',
'novell','netware',
'novell','novell',
'omnihttpd','OmniHTTPd',
'oracle','oracle',
'sambar','Sambar',
'savant','Savant',
'simpleserver','SimpleServer',
'sun','Sun_WebServer',
'tivo','Tivo Calypso',
'tivo','tivo-httpd',
'tivoli','ADSM_HTTP',
'w4','w4',
'wasd','HTTPd-WASD',
'weblogic','weblogic',
'webserver4d','Web_Server_4D',
'website','website',
'zeus','zeus'
];

if (!(document.location.protocol == 'http:' || document.location.protocol == 'https:'))
	return;

var url = document.location.protocol + '//' + document.location.host;

$.xhr({
	method: 'HEAD',
	url: url,
	onload: function (response) {
		var server = response.headers['Server'];
		var server = (server != undefined)?server:response.headers['server'];

		if (!server)
			$.log('server on ' + url + ' detected as "unknown".');

		for (var i = 1; i < signatures.length; i += 2) {
			var sigServer = signatures[i - 1];
			var sigHeader = signatures[i];

			var r = new RegExp(sigServer,'i');

			if (server.match(r)) {
				$.log('server on ' + url + ' detected as "' + sigHeader + '".');

				return;
			}
		}


		if (server)
			$.log('server on ' + url + ' detected as "' + server + '".');
	}});